import * as actionTypes from './actionTypes'
import { User } from '@/model/store/user'
const user: User = {
  token: '',
  realName: '',
  loginName: ''
}

export default function reducer(state = user, action: any) {
  const { type, token, realName, loginName } = action
  switch (type) {
    case actionTypes.TOKEN:
      return { ...state, token }
    case actionTypes.REALNAME:
      return { ...state, realName }
    case actionTypes.LOGINNAME:
      return { ...state, loginName }
  }
  return state
}
